package com.haishuibutian.rocketmqproducer.web;

import com.haishuibutian.rocketmqproducer.rocketmq.MQProducer;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ProducerController {

    @Resource
    private MQProducer<String> mqProducer;

    //RocketMQTemplate


    @GetMapping("/send")
    public void send1(String message,String topic,String tag){
        System.out.printf(" message:%s topic:%s tag:%s",message,topic,tag);

        mqProducer.sendMessage(message,topic,tag);
    }

    /*@GetMapping("/send2/{message}")
    public void send2(@PathVariable("message") String message){
        System.out.println(message);
        rocketMQTemplate.convertAndSend("test_topic",message);
    }*/
}
